import React, { memo, useEffect } from 'react'
import { EntireWrapper } from './style'
import EntireFilter from './c-cpns/entire-filter';
import EntireRooms from './c-cpns/entire-rooms';
import EntirePagination from './c-cpns/entire-pagination';
import { useDispatch } from 'react-redux';
import { fetchRoomListAction } from 'src/store/modules/entire/createActions';
import { changeHeaderConfigAction } from 'src/store/main';
import useScrollTop from '@/hooks/useScrollTop';

const Entire = memo(() => {
  // 发送网络请求
  const dispatch = useDispatch()

  useEffect(() => { 
    dispatch(fetchRoomListAction())

    // header 
    dispatch(changeHeaderConfigAction({isFixed:true}))
  }, [dispatch])
  
  useScrollTop()
  return (
    <EntireWrapper>
      <EntireFilter />
      <EntireRooms />
      <EntirePagination />
    </EntireWrapper>
  );
})

export default Entire